package db

import (
	"log"
)

var UserList = make(map[int]*User)
var WxUserList = make(map[string]*User)

var RolesList = make(map[int]*Role) // key  用户id

var GameCacheMap *GameCache

var CdkTypeCacheMap *CdkTypeCache

// 加载所有缓存
func LoadAllCache() {
	var err error
	u := new(User)
	err = u.CacheUsers()
	if err != nil {
		log.Println("user表缓存加载失败!!!!!!!!,err = ", err)
		panic(err)
		return
	}
	log.Println("user表 - 缓存加载成功!!")

	r := new(Role)
	err = r.CacheRoles()
	if err != nil {
		log.Println("role表缓存加载失败!!!!!!!!,err = ", err)
		panic(err)
		return
	}
	log.Println("role表 - 缓存加载成功!!")

	// 加载游戏表缓存
	GameCacheMap = NewGameCache()
	err = RefreshGameCache()
	if err != nil {
		log.Println("game表缓存加载失败!!!!!!!!,err = ", err)
		panic(err)
		return
	}
	log.Println("game表 - 缓存加载成功!!")

	// 加载cdk类表缓存
	CdkTypeCacheMap = NewCdkTypeCache()
	err = RefreshCdkTypeCache()
	if err != nil {
		log.Println("cdk类表缓存加载失败!!!!!!!!,err = ", err)
		panic(err)
		return
	}
	log.Println("cdk类表 - 缓存加载成功!!")
}
